<template>
  <div class="task-container">
    <div class="header">
      <span>筛选与查询，默认查询当前登录用户为creator的task</span>
    </div>
    <div class="task-grid">
      <div v-for="(task, index) in tasks" :key="index" class="task-card">
        <div class="task-info">
          <span class="task-name">{{ task.name }}</span>
          <span class="task-creator">Creator: {{ task.creator }}</span>
        </div>
        <button @click="deleteTask(index)" class="delete-button">删除</button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';

// 模拟任务数据
const tasks = ref([
  { name: 'Task 1', creator: 'User 1' },
  { name: 'Task 2', creator: 'User 2' },
  // 更多任务...
]);

// 删除任务的方法
const deleteTask = (index: number) => {
  tasks.value.splice(index, 1);
};
</script>

<style scoped>
.task-container {
  padding: 20px;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.task-card {
  border: 1px solid #333;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-info {
  display: flex;
  flex-direction: column;
}

.task-name {
  font-size: 16px;
  margin-bottom: 5px;
}

.task-creator {
  font-size: 14px;
  color: #999;
}

.delete-button {
  background-color: #ff4d4f;
  color: #fff;
  border: none;
  padding: 5px 10px;
  cursor: pointer;
  border-radius: 3px;
}


</style>
